package com.etc.controller;

import com.etc.entity.SysUser;
import com.etc.service.SysOrderService;
import com.etc.service.SysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.io.PrintWriter;

@Controller
@RequestMapping("vip")
public class VipController {

    @Autowired
    private SysUserService sysUserService;

    @Autowired
    private SysOrderService sysOrderService;

    @RequestMapping("index")
    public String get(HttpServletRequest request, HttpSession session){
        request.setAttribute("orderconet",sysOrderService.findByweiOrder().size());
        SysUser sysUser = (SysUser) session.getAttribute("user");
        sysUser = sysUserService.findById(String.valueOf(sysUser.getId()));
        request.setAttribute("user",sysUser);
        return "userAdmin/vip";
    }

    /**
     *
     * @param out
     * @param id 用户id
     * @param number 充值金额
     */
    @RequestMapping("chongzhi")
    public void  choangzhi(PrintWriter out,String id,String nmeber){
        Integer restsle  = sysUserService.chognzhi(id,nmeber);
        if (restsle == 1){
            out.print(1);
        }else {
            out.print(2);
        }
    }
}
